package com.my.chapter9;

import java.io.IOException;
import java.nio.CharBuffer;
import java.util.Random;
import java.util.Scanner;

public class practice16 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new AdaptedRandomChars(6));
        while(sc.hasNext()){
            System.out.println(sc.next());
        }
    }
}

class RandomChars{
    private static Random rand = new Random(2);
    private static final char[] capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
    private static final char[] lowers = "abcdefghijklmnopqrstuvwxyz".toCharArray();
    public String next(){
        StringBuffer sb = new StringBuffer();
        sb.append(capitals[rand.nextInt(26)]);
        for(int i=0;i<9;i++){
            sb.append(lowers[rand.nextInt(26)]);
        }
        return sb.toString();
    }
}

class AdaptedRandomChars extends RandomChars implements Readable{
    private int count;
    public AdaptedRandomChars(int count){
        this.count = count;
    }

    @Override
    public int read(CharBuffer cb) throws IOException {
        if(count-- == 0){
            return -1;
        }
        String result = next()+" ";
        cb.append(result);
        return result.length();
    }
}